{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts import Boxplot\n",
    "from pyecharts import Bar \n",
    "from pyecharts import Pie\n",
    "from pyecharts import Scatter\n",
    "from pyecharts import WordCloud\n",
    "import numpy as np\n",
    "from snownlp import SnowNLP\n",
    "import jieba\n",
    "# from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator\n",
    "from matplotlib import pyplot as plt\n",
    "import os\n",
    "import collections\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "title_class = '厨房用品、厨房电器'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "导出数据共有24203行，8列！\n",
      "读取数据源成功！！\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"b1e7f98f25984cd6ab4362e8d3f20329\" style=\"width:1500px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_b1e7f98f25984cd6ab4362e8d3f20329 = echarts.init(document.getElementById('b1e7f98f25984cd6ab4362e8d3f20329'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_b1e7f98f25984cd6ab4362e8d3f20329 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u5c0f\\u7c7b\\u7bb1\\u7ebf\\u56fe\\u68c0\\u6d4b\\u5f02\\u5e38\\u503c\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 6193062,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u5c0f\\u7c7b\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    69.0,\n",
       "                    106.5,\n",
       "                    174.0,\n",
       "                    406.5,\n",
       "                    2698.0\n",
       "                ],\n",
       "                [\n",
       "                    59.0,\n",
       "                    143.5,\n",
       "                    278.0,\n",
       "                    408.5,\n",
       "                    798.0\n",
       "                ],\n",
       "                [\n",
       "                    69.0,\n",
       "                    174.0,\n",
       "                    239.0,\n",
       "                    358.5,\n",
       "                    1788.0\n",
       "                ],\n",
       "                [\n",
       "                    29.0,\n",
       "                    92.0,\n",
       "                    143.5,\n",
       "                    220.75,\n",
       "                    1980.0\n",
       "                ],\n",
       "                [\n",
       "                    29.0,\n",
       "                    115.0,\n",
       "                    179.0,\n",
       "                    548.0,\n",
       "                    1288.0\n",
       "                ],\n",
       "                [\n",
       "                    30.0,\n",
       "                    73.5,\n",
       "                    138.0,\n",
       "                    243.0,\n",
       "                    499.0\n",
       "                ],\n",
       "                [\n",
       "                    27.0,\n",
       "                    67.5,\n",
       "                    138.0,\n",
       "                    238.0,\n",
       "                    3999.0\n",
       "                ],\n",
       "                [\n",
       "                    178.0,\n",
       "                    300.0,\n",
       "                    709.0,\n",
       "                    1189.0,\n",
       "                    1799.0\n",
       "                ],\n",
       "                [\n",
       "                    89.0,\n",
       "                    266.5,\n",
       "                    2384.0,\n",
       "                    4690.75,\n",
       "                    6399.0\n",
       "                ],\n",
       "                [\n",
       "                    169.0,\n",
       "                    578.0,\n",
       "                    999.0,\n",
       "                    2143.0,\n",
       "                    2998.0\n",
       "                ],\n",
       "                [\n",
       "                    169.0,\n",
       "                    648.25,\n",
       "                    1198.5,\n",
       "                    1984.75,\n",
       "                    10880.0\n",
       "                ],\n",
       "                [\n",
       "                    499.0,\n",
       "                    1790.0,\n",
       "                    2999.0,\n",
       "                    4199.0,\n",
       "                    8260.0\n",
       "                ],\n",
       "                [\n",
       "                    49.0,\n",
       "                    115.75,\n",
       "                    163.0,\n",
       "                    894.25,\n",
       "                    2980.0\n",
       "                ],\n",
       "                [\n",
       "                    69.0,\n",
       "                    240.75,\n",
       "                    634.0,\n",
       "                    1394.25,\n",
       "                    8800.0\n",
       "                ],\n",
       "                [\n",
       "                    29.9,\n",
       "                    89.0,\n",
       "                    188.0,\n",
       "                    368.0,\n",
       "                    1980.0\n",
       "                ],\n",
       "                [\n",
       "                    119.0,\n",
       "                    204.0,\n",
       "                    363.0,\n",
       "                    598.5,\n",
       "                    999.0\n",
       "                ],\n",
       "                [\n",
       "                    129.0,\n",
       "                    276.5,\n",
       "                    478.5,\n",
       "                    1413.75,\n",
       "                    2680.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    144.0,\n",
       "                    244.0,\n",
       "                    376.5,\n",
       "                    1399.0\n",
       "                ],\n",
       "                [\n",
       "                    59.0,\n",
       "                    84.0,\n",
       "                    119.0,\n",
       "                    154.0,\n",
       "                    269.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    333.25,\n",
       "                    534.0,\n",
       "                    803.75,\n",
       "                    2998.0\n",
       "                ],\n",
       "                [\n",
       "                    199.0,\n",
       "                    399.0,\n",
       "                    699.0,\n",
       "                    999.0,\n",
       "                    1520.0\n",
       "                ],\n",
       "                [\n",
       "                    50.0,\n",
       "                    231.25,\n",
       "                    429.0,\n",
       "                    1098.75,\n",
       "                    3999.0\n",
       "                ],\n",
       "                [\n",
       "                    88.0,\n",
       "                    181.25,\n",
       "                    263.5,\n",
       "                    429.0,\n",
       "                    1699.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    329.0,\n",
       "                    1080.0,\n",
       "                    1498.0,\n",
       "                    3399.0\n",
       "                ],\n",
       "                [\n",
       "                    109.0,\n",
       "                    478.5,\n",
       "                    1399.0,\n",
       "                    2448.0,\n",
       "                    15888.0\n",
       "                ],\n",
       "                [\n",
       "                    158.0,\n",
       "                    174.0,\n",
       "                    219.0,\n",
       "                    593.5,\n",
       "                    1299.0\n",
       "                ],\n",
       "                [\n",
       "                    49.0,\n",
       "                    101.25,\n",
       "                    143.5,\n",
       "                    228.0,\n",
       "                    335.0\n",
       "                ],\n",
       "                [\n",
       "                    1698.0,\n",
       "                    1799.0,\n",
       "                    2580.0,\n",
       "                    3999.0,\n",
       "                    8299.0\n",
       "                ],\n",
       "                [\n",
       "                    358.0,\n",
       "                    378.5,\n",
       "                    498.0,\n",
       "                    1148.5,\n",
       "                    1199.0\n",
       "                ],\n",
       "                [\n",
       "                    73.0,\n",
       "                    131.0,\n",
       "                    398.0,\n",
       "                    2239.0,\n",
       "                    3980.0\n",
       "                ],\n",
       "                [\n",
       "                    79.0,\n",
       "                    114.0,\n",
       "                    169.0,\n",
       "                    254.0,\n",
       "                    309.0\n",
       "                ],\n",
       "                [\n",
       "                    149.0,\n",
       "                    271.5,\n",
       "                    399.0,\n",
       "                    665.75,\n",
       "                    3218.0\n",
       "                ],\n",
       "                [\n",
       "                    25.8,\n",
       "                    59.849999999999994,\n",
       "                    136.5,\n",
       "                    248.25,\n",
       "                    98888.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 6193062\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c7b\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"\\u9910\\u5177\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_b1e7f98f25984cd6ab4362e8d3f20329.setOption(option_b1e7f98f25984cd6ab4362e8d3f20329);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.boxplot.Boxplot at 0x4b679e8>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = pd.read_csv('./data_list/data_list_after_groupby.csv', sep=',', header=0, encoding='utf-8',engine='python',dtype=str)\n",
    "# data = data.iloc[:10001, :]\n",
    "data = data[data['title'] == title_class]\n",
    "print('导出数据共有{}行，{}列！'.format(data.shape[0], data.shape[1]))\n",
    "print('读取数据源成功！！')   \n",
    "    \n",
    "# 按小类箱线图检测异常值  ——  pyecharts\n",
    "title_name = data['cate'].unique()\n",
    "title_name = list(title_name)\n",
    "title_price = []\n",
    "for title in title_name:\n",
    "    pro_price = data[data['cate']==title]['pro_price'].astype(float).unique()\n",
    "    pro_price = list(pro_price)\n",
    "    title_price.append(pro_price)\n",
    "# print(f'title_price是 {np.array(title_price).shape[0]}维数据')\n",
    "file_name = 'boxplot_' + title_class + '_output.html'\n",
    "boxplot = Boxplot('按小类箱线图检测异常值',width=1500, height=400)\n",
    "x_axis = title_name\n",
    "y_axis = title_price\n",
    "_yaxis = boxplot.prepare_data(y_axis)\n",
    "boxplot.add('小类', x_axis, _yaxis,xaxis_rotate=45,width=1600,height=800)\n",
    "boxplot.render(os.path.join('./data_list',file_name))\n",
    "boxplot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"3f3efcce6f044579a5d7885d7f14d407\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_3f3efcce6f044579a5d7885d7f14d407 = echarts.init(document.getElementById('3f3efcce6f044579a5d7885d7f14d407'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_3f3efcce6f044579a5d7885d7f14d407 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u5206\\u533a\\u95f4\\u76f4\\u65b9\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 4406238,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u5206\\u533a\\u95f4\",\n",
       "            \"data\": [\n",
       "                3127.0,\n",
       "                1070.0,\n",
       "                912.0,\n",
       "                812.0,\n",
       "                921.0,\n",
       "                1040.0,\n",
       "                1255.0,\n",
       "                1568.0,\n",
       "                2490.0,\n",
       "                11008.0\n",
       "            ],\n",
       "            \"barCategoryGap\": 0,\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 4406238\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u5206\\u533a\\u95f4\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"0\",\n",
       "                \"0.1\",\n",
       "                \"0.2\",\n",
       "                \"0.3\",\n",
       "                \"0.4\",\n",
       "                \"0.5\",\n",
       "                \"0.6\",\n",
       "                \"0.7\",\n",
       "                \"0.8\",\n",
       "                \"0.9\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_3f3efcce6f044579a5d7885d7f14d407.setOption(option_3f3efcce6f044579a5d7885d7f14d407);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2db75fd0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评分区间直方图  ——  pyecharts\n",
    "sentiment_score = data['sentiment_score'].astype(float)\n",
    "group = [0, 0.1, 0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]\n",
    "data['group_num'] = pd.cut(sentiment_score, group, labels=['0', '0.1', '0.2', '0.3','0.4','0.5','0.6','0.7','0.8','0.9','1.0'],right=False)\n",
    "data_hist = pd.pivot_table(data,index=['group_num'],values=['sentiment_score'],aggfunc=[len])\n",
    "data_hist.reset_index(inplace=True)\n",
    "data_hist.sort_values(by='group_num',ascending=True,inplace=True)\n",
    "x_axis_list = list(data_hist['group_num'])\n",
    "y_axis_list = list(data_hist[('len','sentiment_score')])\n",
    "# print(x_axis_list,y_axis_list)\n",
    "bar = Bar('评分区间直方图 ')\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评分区间', x_axis, y_axis,bar_category_gap=0,is_label_show=True)\n",
    "file_name = 'hist_' + title_class + '_output.html'\n",
    "bar.render(os.path.join('./data_list',file_name))\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1    好评\n",
      "2    差评\n",
      "0    中评\n",
      "Name: group, dtype: object 1    15718\n",
      "2     5503\n",
      "0     2982\n",
      "Name: (len, item_id), dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"09081e50ee794c5c91a23807f156c58c\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_09081e50ee794c5c91a23807f156c58c = echarts.init(document.getElementById('09081e50ee794c5c91a23807f156c58c'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_09081e50ee794c5c91a23807f156c58c = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u8bba\\u5206\\u7c7b\\u997c\\u56fe\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 4679359,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u8bc4\",\n",
       "                    \"value\": 15718\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5dee\\u8bc4\",\n",
       "                    \"value\": 5503\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u8bc4\",\n",
       "                    \"value\": 2982\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"40%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"outside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 4679359\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u597d\\u8bc4\",\n",
       "                \"\\u5dee\\u8bc4\",\n",
       "                \"\\u4e2d\\u8bc4\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"left\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_09081e50ee794c5c91a23807f156c58c.setOption(option_09081e50ee794c5c91a23807f156c58c);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.pie.Pie at 0x2dbb9c50>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评论分类饼图  ——  pyecharts\n",
    "pie_data = pd.pivot_table(data,index=['group'],values=['item_id'],aggfunc=[len])\n",
    "pie_data.reset_index(inplace=True)\n",
    "pie_data.sort_values(by=('len','item_id'),ascending=False,inplace=True)\n",
    "size = pie_data[('len','item_id')]\n",
    "labels = pie_data['group']\n",
    "print(labels,size)\n",
    "pie = Pie('评论分类饼图', title_pos='center')\n",
    "attr = list(labels)\n",
    "v1 = list(size)\n",
    "pie.add('', attr, v1,radius=[40, 75],label_text_color=None,is_label_show=True,legend_orient='vertical',legend_pos='left')\n",
    "file_name = 'pie_' + title_class + '_output.html'\n",
    "pie.render(os.path.join('./data_list',file_name))\n",
    "pie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"a43d05cd532d4693b3b0e0a05332d159\" style=\"width:800px;height:1000px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_a43d05cd532d4693b3b0e0a05332d159 = echarts.init(document.getElementById('a43d05cd532d4693b3b0e0a05332d159'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_a43d05cd532d4693b3b0e0a05332d159 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5c0f\\u7c7b\\u6761\\u5f62\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 6236835,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u6570\",\n",
       "            \"data\": [\n",
       "                23,\n",
       "                29,\n",
       "                33,\n",
       "                47,\n",
       "                56,\n",
       "                102,\n",
       "                107,\n",
       "                109,\n",
       "                113,\n",
       "                127,\n",
       "                130,\n",
       "                186,\n",
       "                214,\n",
       "                334,\n",
       "                410,\n",
       "                426,\n",
       "                608,\n",
       "                790,\n",
       "                814,\n",
       "                826,\n",
       "                851,\n",
       "                852,\n",
       "                882,\n",
       "                910,\n",
       "                1073,\n",
       "                1168,\n",
       "                1272,\n",
       "                1618,\n",
       "                1801,\n",
       "                1841,\n",
       "                1917,\n",
       "                2000,\n",
       "                2534\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"right\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 6236835\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u8bba\\u6570\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"\\u9910\\u5177\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_a43d05cd532d4693b3b0e0a05332d159.setOption(option_a43d05cd532d4693b3b0e0a05332d159);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2dbb9cf8>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：小类条形图  ——  pyecharts\n",
    "hbar_data = pd.pivot_table(data,index=['cate'],values=['item_id'],aggfunc=[len])\n",
    "hbar_data.reset_index(inplace=True)\n",
    "hbar_data.sort_values(by=('len','item_id'),ascending=True,inplace=True)\n",
    "title_name = hbar_data['cate']\n",
    "size = hbar_data[('len','item_id')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(size)\n",
    "bar = Bar('小类条形图 ',width=800, height=1000)\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评论数', x_axis, y_axis,is_convert=True,is_label_show=True,label_pos='right')\n",
    "file_name = 'hbar_' + title_class + '_output.html'\n",
    "bar.render(os.path.join('./data_list',file_name))\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"476082201fc545e2adab247bfde2197b\" style=\"width:1500px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_476082201fc545e2adab247bfde2197b = echarts.init(document.getElementById('476082201fc545e2adab247bfde2197b'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_476082201fc545e2adab247bfde2197b = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5c0f\\u7c7b\\u8bc4\\u8bba\\u5206\\u6570\\u67f1\\u72b6\\u56fe \",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 4289032,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u5206\\u6570\",\n",
       "            \"data\": [\n",
       "                \"0.84\",\n",
       "                \"0.79\",\n",
       "                \"0.77\",\n",
       "                \"0.75\",\n",
       "                \"0.75\",\n",
       "                \"0.74\",\n",
       "                \"0.73\",\n",
       "                \"0.73\",\n",
       "                \"0.72\",\n",
       "                \"0.72\",\n",
       "                \"0.72\",\n",
       "                \"0.71\",\n",
       "                \"0.70\",\n",
       "                \"0.69\",\n",
       "                \"0.69\",\n",
       "                \"0.68\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.66\",\n",
       "                \"0.66\",\n",
       "                \"0.66\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.64\",\n",
       "                \"0.64\",\n",
       "                \"0.63\",\n",
       "                \"0.62\",\n",
       "                \"0.58\",\n",
       "                \"0.52\"\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 4289032\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u8bba\\u5206\\u6570\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u9910\\u5177\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_476082201fc545e2adab247bfde2197b.setOption(option_476082201fc545e2adab247bfde2197b);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x2dbd7780>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 双变量：小类、评论分数柱状图  ——  pyecharts\n",
    "data['sentiment_score'] = data['sentiment_score'].astype(float)\n",
    "bar_data = pd.pivot_table(data,index=['cate'],values=['sentiment_score'],aggfunc=[np.mean])\n",
    "bar_data.reset_index(inplace=True)\n",
    "bar_data.sort_values(by=('mean','sentiment_score'),ascending=False,inplace=True)\n",
    "f = lambda x: '%.2f'%x\n",
    "bar_data[('mean','sentiment_score')] = bar_data[('mean','sentiment_score')].map(f)\n",
    "title_name = bar_data['cate']\n",
    "score = bar_data[('mean','sentiment_score')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(score)\n",
    "bar = Bar('小类评论分数柱状图 ',width=1500, height=400)\n",
    "x_axis = x_axis_list\n",
    "y_axis = y_axis_list\n",
    "bar.add('评论分数', x_axis, y_axis,xaxis_rotate=45,is_label_show=True)\n",
    "file_name = 'bar_' + title_class + '_output.html'\n",
    "bar.render(os.path.join('./data_list',file_name))\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 双变量：价格、评论分数散点图  ——  pyecharts\n",
    "# sentiment_score = data['sentiment_score'].astype(float)\n",
    "# pro_price = data['pro_price'].astype(float)\n",
    "# x_axis_list = list(sentiment_score)\n",
    "# y_axis_list = list(pro_price)\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# scatter = Scatter('价格评论分数散点图')\n",
    "# scatter.add('', x_axis, y_axis, symbol_size=5,is_visualmap=True)\n",
    "# scatter.render('./data_list/scatter_all_output.html')\n",
    "# scatter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "DEBUG:jieba:Building prefix dict from the default dictionary ...\n",
      "Loading model from cache C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\jieba.cache\n",
      "DEBUG:jieba:Loading model from cache C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\jieba.cache\n",
      "Loading model cost 0.997 seconds.\n",
      "DEBUG:jieba:Loading model cost 0.997 seconds.\n",
      "Prefix dict has been built succesfully.\n",
      "DEBUG:jieba:Prefix dict has been built succesfully.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min', 'wordcloud': '/nbextensions/echarts/echarts-wordcloud.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"a0debc181f9a46a4961e64332dadcd2e\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts', 'wordcloud'], function(echarts) {\n",
       "        \n",
       "var myChart_a0debc181f9a46a4961e64332dadcd2e = echarts.init(document.getElementById('a0debc181f9a46a4961e64332dadcd2e'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_a0debc181f9a46a4961e64332dadcd2e = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7208613,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"wordCloud\",\n",
       "            \"name\": \"\\u8bc4\\u8bba\\u8bcd\\u4e91\\u56fe\",\n",
       "            \"shape\": \"diamond\",\n",
       "            \"rotationRange\": [\n",
       "                0,\n",
       "                0\n",
       "            ],\n",
       "            \"rotationStep\": 45,\n",
       "            \"girdSize\": 20,\n",
       "            \"sizeRange\": [\n",
       "                10,\n",
       "                100\n",
       "            ],\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u559c\\u6b22\",\n",
       "                    \"value\": 2937,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(114,127,27)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6ee1\\u610f\",\n",
       "                    \"value\": 2468,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(79,7,75)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d28\\u91cf\",\n",
       "                    \"value\": 2345,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(55,50,23)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fdd\\u6e29\",\n",
       "                    \"value\": 1831,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(156,103,53)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4ef7\\u683c\",\n",
       "                    \"value\": 1459,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(155,11,63)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6548\\u679c\",\n",
       "                    \"value\": 1316,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(26,85,72)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b9e\\u7528\",\n",
       "                    \"value\": 1189,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(73,125,127)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5f88\\u5feb\",\n",
       "                    \"value\": 1172,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(85,54,137)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u503c\\u5f97\",\n",
       "                    \"value\": 1030,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(71,118,100)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9001\\u8d27\",\n",
       "                    \"value\": 959,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(20,27,60)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u7528\",\n",
       "                    \"value\": 924,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(118,68,112)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b9e\\u60e0\",\n",
       "                    \"value\": 891,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(89,80,122)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u989c\\u8272\",\n",
       "                    \"value\": 839,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(39,160,66)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u901f\\u5ea6\",\n",
       "                    \"value\": 825,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(111,159,60)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7269\\u6d41\",\n",
       "                    \"value\": 795,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(63,3,85)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u54c1\\u724c\",\n",
       "                    \"value\": 755,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(137,58,156)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5feb\\u9012\",\n",
       "                    \"value\": 739,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(64,92,61)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6ca1\\u7528\",\n",
       "                    \"value\": 709,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(66,63,76)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u770b\",\n",
       "                    \"value\": 688,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(98,5,16)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u914d\\u9001\",\n",
       "                    \"value\": 682,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(117,23,90)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6f02\\u4eae\",\n",
       "                    \"value\": 637,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(96,149,88)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5916\\u89c2\",\n",
       "                    \"value\": 618,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(18,80,116)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5305\\u88c5\",\n",
       "                    \"value\": 604,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(74,3,93)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5927\\u5c0f\",\n",
       "                    \"value\": 596,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(90,110,20)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u6d17\",\n",
       "                    \"value\": 571,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(7,148,152)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u676f\\u5b50\",\n",
       "                    \"value\": 569,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(146,85,118)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9505\\u5b50\",\n",
       "                    \"value\": 566,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(133,146,129)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u653e\\u5fc3\",\n",
       "                    \"value\": 531,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(98,72,49)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670b\\u53cb\",\n",
       "                    \"value\": 529,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(152,124,147)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5bb9\\u91cf\",\n",
       "                    \"value\": 505,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(108,150,159)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670d\\u52a1\",\n",
       "                    \"value\": 501,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(40,153,94)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63a8\\u8350\",\n",
       "                    \"value\": 485,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(148,117,67)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fbf\\u5b9c\",\n",
       "                    \"value\": 474,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(155,89,79)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fe1\\u8d56\",\n",
       "                    \"value\": 450,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(45,12,145)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u88c5\",\n",
       "                    \"value\": 448,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(0,20,41)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u53cc\\u7acb\\u4eba\",\n",
       "                    \"value\": 447,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(128,66,136)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6027\\u4ef7\\u6bd4\",\n",
       "                    \"value\": 442,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(61,8,127)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65f6\\u95f4\",\n",
       "                    \"value\": 437,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(35,139,26)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5f88\\u6f02\\u4eae\",\n",
       "                    \"value\": 427,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(26,92,133)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u76d6\\u5b50\",\n",
       "                    \"value\": 404,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(112,13,112)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0d\\u9508\\u94a2\",\n",
       "                    \"value\": 391,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(151,124,36)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73bb\\u7483\",\n",
       "                    \"value\": 389,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(109,2,24)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u724c\\u5b50\",\n",
       "                    \"value\": 364,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(3,60,152)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4f7f\\u7528\\u65b9\\u4fbf\",\n",
       "                    \"value\": 347,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(14,68,78)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c0f\\u5de7\",\n",
       "                    \"value\": 346,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(127,38,14)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u58f0\\u97f3\",\n",
       "                    \"value\": 342,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(95,138,120)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u51c0\",\n",
       "                    \"value\": 327,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(25,144,69)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5200\\u5177\",\n",
       "                    \"value\": 322,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(155,158,60)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9002\\u5408\",\n",
       "                    \"value\": 316,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(56,19,63)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5546\\u54c1\\u8d28\\u91cf\",\n",
       "                    \"value\": 314,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(159,112,24)\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_a0debc181f9a46a4961e64332dadcd2e.setOption(option_a0debc181f9a46a4961e64332dadcd2e);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.wordcloud.WordCloud at 0x2dbe7be0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 词云  ——  pyecharts \n",
    "data_cut_words = pd.DataFrame(data.astype(str))\n",
    "# data_cut_words['cut_comment'] = data_duplicate_words['seg_comment'].apply(cut_words)\n",
    "# stopwords = load_stopwords()\n",
    "stopwords = [line.strip() for line in open('./常见中文停用词表.txt', encoding='gbk').readlines()]\n",
    "# 保存全局分词，用于词频统计\n",
    "segments = []\n",
    "# 普通分词及停用词判断\n",
    "for index, row in data_cut_words.iterrows():\n",
    "    content = row[5]\n",
    "    # TextRank 关键词抽取，只获取固定词性\n",
    "    words = jieba.cut(content,cut_all=False)\n",
    "    # splitedStr = ''\n",
    "    for word in words:\n",
    "        # 停用词判断，如果当前的关键词不在停用词库中才进行记录\n",
    "        if word not in stopwords:\n",
    "            # 记录全局分词\n",
    "            segments.append(word)\n",
    "            # splitedStr += word + ' '\n",
    "word_counts = collections.Counter(segments) # 对分词做词频统计\n",
    "word_counts_top10 = word_counts.most_common(50) # 获取前50最高频的词\n",
    "# print ('文本词频最高的前50个词是: {}'.format(word_counts_top10)) # 输出检查\n",
    "# 设置中文字体\n",
    "# font_path = os.path.join('C:\\Windows\\Fonts', 'FZYTK.TTF')\n",
    "# 生成词云\n",
    "# wc = WordCloud(font_path=font_path, margin=2, scale=10, max_words=200, min_font_size=4,random_state=42, background_color='white', max_font_size=150)\n",
    "# wc.generate_from_frequencies(word_counts)\n",
    "# 获取文本词排序，可调整 stopwords\n",
    "# process_word = WordCloud.process_text(wc, text)\n",
    "# sort = sorted(process_word.items(), key=lambda e: e[1], reverse=True)\n",
    "# 获取文本词频最高的前50个词\n",
    "# print('文本词频最高的前50个词是: {}'.format(sort[:50]))\n",
    "\n",
    "words = []\n",
    "counts = []\n",
    "\n",
    "for item in word_counts_top10:\n",
    "    word = item[0]\n",
    "    count = item[1]\n",
    "    words.append(word)\n",
    "    counts.append(count)\n",
    "    \n",
    "attr = words\n",
    "value = counts\n",
    "wordcloud = WordCloud(width=800, height=400)\n",
    "wordcloud.add('评论词云图', attr, value,word_size_range=[10, 100],shape='diamond')\n",
    "file_name = 'wordcloud_' + title_class + '_output.html'\n",
    "wordcloud.render(os.path.join('./data_list',file_name))\n",
    "wordcloud"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
